package org.boyan.modules.service.impl;

import org.boyan.entity.esb.ESBServer;
import org.boyan.entity.trans.Trans;
import org.boyan.modules.mapper.TransMapper;
import org.boyan.modules.service.TransService;
import org.boyan.modules.vo.TransVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

@Service
public class TransServiceImpl implements TransService {
    @Autowired
    private TransMapper transMapper;

    @Override
    public boolean addTransList(List<Trans> transList) {
        return transMapper.addTransList(transList)==transList.size();
    }

    @Override
    @Transactional
    public boolean editTransList(List<Trans> transList) {
        for(Trans trans:transList){
            if(transMapper.editTrans(trans)!=1){
                return false;
            }
        }
        return true;

    }

    @Override
    public List<Trans> getTransListByCaseId(String caseId) {
        return transMapper.getTransListByCaseId(caseId);
    }

    @Override
    public boolean deleteTrans(List<Trans> transList) {
        for(Trans t:transList){
            if(transMapper.deleteTransByCaseId(t.getId())!=1){
                return false;
            }
        }
        return true;
    }

    @Override
    public boolean updateESB(ESBServer esbServer) {
        return transMapper.updateESB(esbServer)==1;
    }

    @Override
    public boolean changeTransStatus(int transStatus, String transCode) {
        return transMapper.changeTransStatus(transStatus,transCode)==1;
    }

    @Override
    public List<TransVO> getTransVOListByCaseId(String id) {
        return transMapper.getTransVOListByCaseId(id);
    }


}
